<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="content-type" content="text/html;charset=utf-8">
		<title>实体管理</title>
		<link rel="stylesheet" type="text/css" media="screen" href="../../../Skin/${themeType}/${themeStyle}/css/main.css" />
		<link rel="stylesheet" type="text/css" media="screen" href="../../../Skin/${themeType}/${themeStyle}/css/jquery.alerts.css" />
		<style type="text/css">
		<!-- 
			ul{list-style:none;}
			li{float:left;}
			.query ul li label{
				display:inline-block; 
				width: 80px;
			}
			.query ul li select{
				width: 250px;
			}
			.query ul li input{
				width: 250px;
			}
			.query ul li input[type=checkbox]{
				width: 50px;
			}
			table { /* 无间隔 */ border-collapse: collapse; /* 无边框 */border-style: none }
			td,th { border: solid 1px; /* 无填充*/ padding: 0 }
			
		-->
		</style>
		<script type="text/javascript" src="../../../js/jquery-1.11.1.min.js"></script>
		<script type="text/javascript">
			var del = function(id) {
				//删除实体
				if (confirm("真的要删除该实体吗？")) {
					pageForm.action = "del";
					var orgId = $("#orgId").val();
					$("#id").val(id);
					pageForm.submit();
				}
			};

			function manage(id) {
				var entityClass = window.document.getElementById("entityClass");
				alert("aaa="+ entityClass);
				alert("entityClass.value ="+entityClass.value);
				entityClass.value = id;
				pageForm.submit();
			}
			
			var add = function() {
				$("#id").val('');
				pageForm.action = "add";
				pageForm.submit();
			};
			
			var breakOrgList = function() {
				var parOrgId = $("#parOrgId").val();
				window.location = "orgManage?parOrgId=" + parOrgId;
				pageForm.submit();
			};
			
			function orgChanged() {
				$("#parent").val(null);
				pageForm.submit();
			}
			
			function parentChanged(parentId) {
				pageForm.submit();
			}
			
			function userManage(orgId) {
				$("#orgId").val(orgId);
				pageForm.submit();
			}
			
			function edit(id) {
				pageForm.action = "edit";
				$("#id").val(id);
				pageForm.submit();
			}
			
			function manageOrg(ortId) {
				$("#orgId").val(ortId);
				pageForm.submit();
			};
			
		</script>
	</head>
	<body>
		<s:form name="pageForm" theme="simple" method="post">
			管理的对象:<s:select name="entityClass" list="entityNameList" listKey="id" listValue="name" emptyOption="true"></s:select>
			<fieldset class="query">
				<legend>
					查询条件
				</legend>
				<ul>
					<s:iterator value="property" id="prop" status="propIndex">
						<li><label><s:property value="#prop"/></label><input type="text" name='page.findByExample.<s:property value="#prop" />' value='<s:property value="page.findByExample[#prop]" />' onchange="pageForm.submit();" class="inputText"> 
<input type="checkbox" name="propertyList" value="<s:property value="#prop"/>" checked="checked" />
						</li>
					</s:iterator>
					<li><a onclick="pageForm.submit();">查询</a></li>
				</ul>
				
			</fieldset>

			<div class="tabBlock">
				<div class="dataGrid">
					<table>
						<tr>
							<th>
								序号
							</th>
						<s:iterator value="property" id="prop" status="propIndex">
							<th>
								<s:property value="prop"/>
							</th>
						</s:iterator>
							<th>
								操作
							</th>
						</tr>
						<s:if test="page.data.size==0">
							<tr class="trStyle">
								<td colspan="<s:property value="property.size+2" />">
									没有找到任何数据！
								</td>
						</s:if>
						<s:iterator value="page.data" id="item" status="st">
							<tr class="trStyle">
								<td style="text-align: center;">
									<s:property value="#st.index+1+(page.pageNo-1)*page.pageSize" />
								</td>

						<s:iterator value="property" id="propValue" status="propIndex1">
						  <s:if test="#propValue=='pkId'">
								<td style="text-align: center;">
									<s:property value="#item.pkId" />
								</td>
						  </s:if>
						  <s:else>
								<td style="text-align: center;">
									<s:property value="#item[#propValue]"/>
								</td>
						  </s:else>
						</s:iterator>

								<td style="text-align: center;">
									<a href="view?item.<s:property value="idName"/>=<s:property value="#item[idName]"/>" style="color: #E9621E;">查看</a>&nbsp;
									<a href="javascript:manage('<s:property value="#item[idName]"/>')" >管理</a>&nbsp;
									<s:if test="#item.manageEnabled">
										<a href="edit?depart.id=<s:property value="#item.id"/>" style="color: #E9621E;">修改</a>&nbsp;
										<a href="javascript:delDepartment(<s:property value="#item.id"/>)" style="color: #E9621E;">删除</a>&nbsp;
										<a href="userManage?depart.id=<s:property value="#item.id"/>" style="color: #E9621E;">管理</a>&nbsp;
									</s:if>
									<s:if test="#item.maxCount!=0">
									<a
										href="manage?parent.id=<s:property value="#item.id"/>"
										style="color: #E9621E;">下级实体</a>
									</s:if>
								</td>
							</tr>
						</s:iterator>
					</table>
					<div class="pagingCtr">
						<s:property escape="false" value="page.pageShowTemplate" />
					</div>
					<s:hidden name="index"></s:hidden>
				</div>
			</div>
			<s:if test="index>0">
					<fieldset class="editBlock">
					<legend>详细信息</legend>
						<table>
						<s:iterator value="property" id="prop" status="propIndex">
							<tr>
								<th style="text-align: left;">
									<s:property value="#prop" />：
								</th>
								<td colspan="3">
									<input type="text" name="item.<s:property value="#prop"/>" value="<s:property value="item[#prop]"/>">
								</td>
							</tr>
						</s:iterator>
						</table>
					</fieldset>
			</s:if>
			<div class="btnSite">
				<div class="longBtn">
					<a onclick="pageForm.submit();" style="text-decoration: none;">刷新</a>
					<s:if test="addEnabled">
					<a onclick="add()" style="text-decoration: none;">添加</a>
				</s:if>
				<a onclick="history.go(-1);" style="text-decoration: none;">返回</a>
				
				</div>
			</div>
		</s:form>
		<div id="message">
			<s:actionerror id="actionError" />
			<s:actionmessage />
		</div>
	</body>
</html>